﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Cci;

namespace AndersLiu.Reflector.Core
{
    class ReflectorHostEnvironment : MetadataReaderHost
    {
        public override IUnit LoadUnitFrom(string location)
        {
            var binDoc = BinaryDocument.GetBinaryDocumentForFile(location, this);
            var unit = _reader.OpenModule(binDoc);

            this.RegisterAsLatest(unit);

            return unit;
        }

        internal ReflectorHostEnvironment()
        {
            _reader = new PeReader(this);
        }

        private PeReader _reader;
    }
}
